package com.adou.multi.multi_tenancy.domain.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.Size;

import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.Parameter;

import com.adou.multi.multi_tenancy.listener.TenantListenter;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@MappedSuperclass
@Getter
@Setter
@NoArgsConstructor
@FilterDef(name = "tenantFilter", parameters={@ParamDef(name = "tenantId", type="string")})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
@EntityListeners(TenantListenter.class)
public abstract class AbstractBaseEntity implements TenantAware, Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Column(name = "tenantId")
	@Size(max = 30)
	private String tenantId;
	
	public AbstractBaseEntity(String tenantId) {
		this.tenantId = tenantId;
	}
	
	
	
	
	
}
